﻿using System;
using System.IO;
using OpenLS.Spreadsheet.Formats.Biff.Tokens;

namespace OpenLS.Spreadsheet.Formats.Biff.Records
{
    internal class DVParsedFormula : ParsedFormulaBase
    {
        private ushort unused;

        public void ReadMe(BinaryReader reader)
        {
#if DEBUG
            ReadWriteChecker.CheckClass((t, r) => t.ReadMe(r), (t, w) => t.WriteMe(w), reader, this);
#endif

            ushort length = reader.ReadUInt16();
            this.unused = reader.ReadUInt16();
            base.Read(new FormulaReadContext(reader, FormulaReadContextType.Default), length);
        }

        public void WriteMe(BinaryWriter writer)
        {
            ushort length = TotalTokenByteLength(FormulaReadContextType.Default);
            writer.Write(length);
            writer.Write(unused);
            base.WriteNamed(new FormulaWriteContext(writer, FormulaReadContextType.Default));
        }

        protected override Cell GetReferenceCell(Cell cell)
        {
            return cell;
        }
    }
}